/**
 * Copyright (C) 2015-2016  Shuishun Zhou  All Rights Reserved.
 * File name:       com_dll_api.h
 * Version:         0.0.1
 * Description:     a simple common dll api for both win msvc and linux gcc
 * Function List:
 * History:
 * No.          Date        Author          Note
 * 01       2015-02-23  Water (sszhouplus@qq.com) Create v0.0.1
 **/
#ifndef __com_dll_api_h_
#define __com_dll_api_h_

#ifdef __cplusplus
extern "C" {
#endif

/**
  * Function: dll_open
  * @brief:   open dll library, and return dll module handle
  * @param:   dll_name : [in] the dll file name for open
  * @return:  void* the dll module handle
  *              0  : error occurs during the process of loading dll file 
  *                More detailed diagnostic information will be available 
  *                  through dl_get_error
  *              !0 : open dll libary ok and return the dll module handle
  */
void *dll_open(const char *dll_name);

/**
  * Function: dll_close
  * @brief:   close dll module
  * @param:   dll_module : [in] the dll module handle (by dll_open)
  * @return:  void* 
  *              0  : close dll module ok
  *              !0 : close dll mdoule ng, and return input dll_module
  *                More detailed diagnostic information will be available 
  *                  through dl_get_error
  */
void *dll_close(void *dll_module);

/**
  * Function: dll_get_symbol
  * @brief:   get function entry from dll module by symbol name
  * @param:   dll_module : [in] the dll module handle (by dll_open)
  *           sym_name:    [in] the symbol name for this function
  * @return:  void* 
  *             0  : get function entry fail from this dll by this symbol name
  *                More detailed diagnostic information will be available 
  *                  through dl_get_error
  *             !0 : get function entry ok and return function pointer addresss
  */
void *dll_get_symbol(void *dll_module, const char *sym_name);

/**
  * Function: dll_last_error
  * @brief:   after dll_open/close/get_symbol function failed
  *             could get the last detailed error information by this function.
  *           if dll_open/close/get_symbol return ok, and call this function
  *            the error information maybe incorrect.
  * @param:   null
  * @return:  char* 
  *              0  : no error information
  *              !0 : the last error information
  */
char *dll_last_error(void);

#ifdef __cplusplus
}
#endif

#endif /* #ifndef __com_dll_api_h_ */
